exports.LoginValidation = function(req,res){

    var bodyParams = req.routeInfo.bodyParams;

    var userData = [];

    //任务流创建
    async.waterfall([

        //验证帐号密码
        function (cb) {

            R.SEND_HTTP(
                req,
                {
                    url: CORE_APIConfig.coreAPI.search_user_info + "/u_type/1/u_username/" + bodyParams.u_username + "/u_password/" + common.md5(bodyParams.u_password),
                    method: 'POST',
                    data: {
                        fields: ["u_id","u_oid"].join(",")
                    }
                },
                function (err, data) {

                    //判断是否有错误信息
                    if (err) {
                        return cb(err, data);
                    }

                    //判断用户是否存在
                    if (data.data.length <= 0) {
                        return RES.response(res, false, "帐号或密码错误，请重新尝试");
                    }

                    userData = data.data;

                    cb();


                }
            )

        },

        //查询机构名
        function(cb){

            var tasks = [];

            userData.forEach(function (item, i) {

                //创建每一个插入任务
                tasks.push(function (callback) {
  
                    console.log(item)

                    R.SEND_HTTP(
                        req,
                        {
                            url: CORE_APIConfig.coreAPI.searchOrganization + "/o_id/" + item.u_oid,
                            method: 'POST',
                            data: {
                                fields: ["o_name"].join(",")
                            }
                        },
                        function (err, data) {

                            if(data.data.length > 0){
                                item.o_name = data.data[0].o_name;
                            }else{
                                item.o_name = "";
                            }

                            callback();

                        });

                });

            });
            async.waterfall(tasks, cb);

        }

    ], function (err, result) {

        //返回最终拼接结果
        RES.response(res, true, userData);

    })

}